package vn.sunnet.backviet01.game.coloa.animated.skill;

import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

public class SkillDragon extends AnimatedSprite{
	private static final long[] durationFire = {60, 60, 60, 80};
//	private static final long[] durationBeat = {50, 50, 80, 80, 50, 50};
	
	private boolean isAttack = false;
	private boolean isChecked = false;
	
	
	public SkillDragon(final int name, float pX, float pY,
			TiledTextureRegion pTiledTextureRegion) {
		super(pX, pY, pTiledTextureRegion);
		
	}
	
	public void onManagedUpdate(float pSecondsElapsed) {
		super.onManagedUpdate(pSecondsElapsed);
		
		if (getCurrentTileIndex() > 2 && getCurrentTileIndex() < 5)
			if (!isChecked) {
				isChecked = true;
				isAttack = true;
		}
	}
	
	public void activeFire(final float pX, final float pY) {
		setPosition(pX - 480, pY - 10);
		this.animate(durationFire, 3, new IAnimationListener() {
			@Override
			public void onAnimationEnd(AnimatedSprite arg0) {
				resetFire();
			}
		});
	}
	
//	public void activeBeat(final float pX, final float pY) {
//		setPosition(pX - 50, pY + 150);
//		this.animate(durationBeat, false, new IAnimationListener() {
//			@Override
//			public void onAnimationEnd(AnimatedSprite arg0) {
//				resetBeat();
//			}
//		});
//	}
	
	public void stopAttack() {
		this.isAttack = false;
		isChecked = false;
	}
	
	public boolean isAttack() {
		return isAttack;
	}
	
	public void resetBeat() {
		isAttack = false;
		isChecked = false;
		this.setVisible(false);
		stopAnimation();
	}
	
	public void resetFire() {
		isAttack = false;
		isChecked = false;
		this.setVisible(false);
		stopAnimation();
	}
}
